package com.backend.modules.notification.entity;

import com.backend.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "notification")
@EqualsAndHashCode(callSuper = true)
@SQLDelete(sql = "UPDATE notification SET deleted = true WHERE id = ?")
@Where(clause = "deleted = false")
public class Notification extends BaseEntity {
    
    /**
     * 接收者ID
     */
    @Column(nullable = false)
    private Long receiverId;
    
    /**
     * 标题
     */
    @Column(nullable = false)
    private String title;
    
    /**
     * 内容
     */
    @Column(columnDefinition = "text")
    private String content;
    
    /**
     * 是否已读
     */
    @Column(name = "`read`", nullable = false, columnDefinition = "bit default 0")
    private Boolean read = false;
    
    /**
     * 通知类型
     */
    @Column(nullable = false)
    private String type;
    
    /**
     * 关联ID
     */
    private Long relatedId;
    
    /**
     * 创建时间
     */
    @Column(nullable = false)
    private LocalDateTime createTime;
} 